// 1.类,属性,方法,参数装饰器组合案例实现  2.执行顺序
function firstMethodDecorator(targetClassPrototype: any, methodname: string) {
  console.log("================执行第一个方法装饰器================");
  console.log("类名:", targetClassPrototype); // 类原型对象变量
  console.log("方法名:", methodname); // key
}

function secondMethodDecorator(params: string) {
  return function (targetClassPrototype: any, methodname: string | symbol) {
    console.log("================执行第二个方法装饰器================");
    console.log("类名:", targetClassPrototype);
    console.log("方法名:", methodname);
  };
}

function paramDecorator(
  targetClassPrototype: any,
  paramname: string | symbol,
  paramindex: number
) {
  console.log("================执行第三个方法装饰器================");
  console.log("targetClassPrototype:", targetClassPrototype);
  console.log("paramname:", paramname);
  console.log("paramindex:", paramindex);
}

function urlPropDecorator(targetClassPrototype: any, attrname: any) {
  console.log("================执行属性装饰器================");
  console.log("targetClassPrototype", targetClassPrototype);
  console.log("属性名", attrname);
}

function URLInfoDecorator(targetClassPrototype: any) {
  console.log("================执行类装饰器================");
  console.log("targetClassPrototype", targetClassPrototype);
}

function constructorDecorator(params: any) {
  return function (
    targetClassPrototype: any,
    paramname?: string,
    paramindex?: number
  ) {
    console.log("================构造器参数装饰器================");
    console.log("构造器参数装饰器:", targetClassPrototype);
    console.log("构造器参数名为:", paramname);
    console.log("构造器参数索引位置:", paramindex);
  };
}

@URLInfoDecorator
class URLInfo {
  constructor(@constructorDecorator("url") public uri: string) {}

  @urlPropDecorator
  public url: string = "https://www.imocc.com";

  @firstMethodDecorator
  methodone(@paramDecorator data: string) {
    console.log("this:", this);
    console.log("目标类:", this.url);
  }

  @secondMethodDecorator("yes")
  methodTwo(@paramDecorator address: string) {
    console.log("address:", address);
  }
}

export {};
